package com.retoc.workflowable.util;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.log.Log;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;

import java.util.logging.Logger;

public class SendMeetingApprove implements JavaDelegate {

//    @Value("${oa.url}")
//    private String url;

    @Override
    public void execute(DelegateExecution execution) {
        String instanceId = execution.getProcessInstanceId();
        String url =(String) execution.getVariable("url");

        JSONObject json=new JSONObject();
        json.set("instanceId",instanceId);

        Object type = execution.getVariable("types");
        json.set("types", type);

        HttpResponse resp = HttpRequest.post(url).header("content-type", "application/json").body(json.toString()).execute();

        System.out.println("resp.body() = " + resp.body());

        System.out.println(instanceId+"已经发送成功！");

    }
}
